package org.scohen.juploadr.prefs;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.scohen.juploadr.uploadapi.ImageUploadApi;

public abstract class BaseConfigurationForm extends Composite implements ConfigurationForm {
    protected ConfigurationDialog parent;
    protected ImageUploadApi api = ImageUploadApi.getInstance();

    public BaseConfigurationForm(Composite parent) {
        super(parent, SWT.NONE);
        initUI();
    }

    public abstract void saveChanges();

    public abstract Fault validateChanges();

    protected abstract void initUI();

    public abstract String getFormName();

    public void setConfigurationDialog(ConfigurationDialog dialog) {
        this.parent = dialog;
    }

    public void accountChanged() {

    }

    protected void resetUI() {
        Control[] kids = this.getChildren();
        for (int i = 0; i < kids.length; i++) {
            Control control = kids[i];
            if (!control.isDisposed()) {
                control.dispose();
            }
        }
    }

}
